Sound and effective data-flow analysis in the presence of aliasing

ABSTRACT

A method, an apparatus, and a computer program product are disclosed that include tracking, using a data flow model of a program suitable for taint analysis of the program, information from sources of taint to entities in a heap using a model of the heap based on the program. The tracking is performed so that the information is relevant for taint propagation and is performed in a manner that is field-sensitive for the entities in the heap. The method, apparatus, and computer program product also include, based on output of the tracking, the operation of performing data-flow analysis to determine taint flow from the sources of the taint through data flow paths to sinks using the taint.

CROSS REFERENCE TO RELATED APPLICATION

The present application claims is a continuation of U.S. patentapplication Ser. No. 13/671,886, filed on Nov. 8, 2012, the disclosureof which is hereby incorporated by reference in its entirety.

BACKGROUND

This invention relates generally to static analysis of program code and,more specifically, relates to data flow analysis.

This section is intended to provide a background or context to theinvention disclosed below. The description herein may include conceptsthat could be pursued, but are not necessarily ones that have beenpreviously conceived, implemented or described. Therefore, unlessotherwise explicitly indicated herein, what is described in this sectionis not prior art to the description in this application and is notadmitted to be prior art by inclusion in this section.

Taint analysis comprises searching for flows of data from untrustedpoints of input (the sources) to sensitive consumers (the sinks). In astatic version of taint analysis, a program is examined withoutexecuting the code making up the program. Instead, a model of theprogram is created. Such a model can include the flows of data,typically represented using a flow graph, which is a representation ofall paths that might be traversed through a program during execution ofthe program. These data flows are potential security issues unless eachdata flow passes through an operation (such as a sanitizer) that rendersthe data safe. Given a call graph G, a static taint analysis algorithmtypically comprises two stages:

1) G is traversed to find sources, sinks and sanitizers in the code:

-   -   Sources are either values obtained through field-read        instructions or values returned from calls to certain methods,        called source methods;    -   Sinks can be either fields of certain objects or parameters of        given methods, called sink methods; and    -   Sanitizers are only methods.

2) An inter-procedural data-flow analysis is performed starting at thesources to determine if there are tainted flows that reach sinks withouthaving been intercepted by sanitizers. The analysis is seeded at thevariables defined by source constructs. That is, the field-readinstructions and source methods are seeded with tainted values and thetainted values are followed via data flow analysis to determine the flowof the taint.

While such analysis is beneficial, there are still problems with theseconventional analyses. One problem that can occur involves aliasing,where, in one example, multiple fields of multiple objects refer to thesame value. Aliasing may also involve relations in the heap, i.e.,multiple local names for the same object. As is known, a heap is an areaof memory used by a program for dynamic memory allocation. In terms oftaint analysis, the model used to emulate a running program would alsoemulate the heap for that program. Aliasing in the heap would beproblematic, as if the object having multiple local names is tainted,all of the multiple local names should also be marked as tainted.However, many taint analysis tools do not consider or cannot handlealiasing in the heap.

BRIEF SUMMARY

In an exemplary embodiment, a method is disclosed that includes, using adata flow model of a program suitable for taint analysis of the program,tracking information from sources of taint to entities in a heap using amodel of the heap based on the program. The tracking is performed sothat the information is relevant for taint propagation and is performedin a manner that is field-sensitive for the entities in the heap. Themethod includes, based on output of the tracking, performing data-flowanalysis to determine taint flow from the sources of the taint throughdata flow paths to sinks using the taint.

In a further exemplary embodiment, an apparatus includes one or morememories and one or more processors, the one or more memories comprisingcomputer-readable code, and the one or more processors in response toexecuting the computer-readable code causing the apparatus to performthe following: using a data flow model of a program suitable for taintanalysis of the program, tracking information from sources of taint toentities in a heap using a model of the heap based on the program,wherein the tracking is performed so that the information is relevantfor taint propagation and is performed in a manner that isfield-sensitive for the entities in the heap; and based on output of thetracking, performing data-flow analysis to determine taint flow from thesources of the taint through data flow paths to sinks using the taint.

In a further exemplary embodiment, an apparatus is disclosed thatcomprises means, using a data flow model of a program suitable for taintanalysis of the program, for tracking information from sources of taintto entities in a heap using a model of the heap based on the program,wherein the tracking is performed so that the information is relevantfor taint propagation and is performed in a manner that isfield-sensitive for the entities in the heap; and means, based on outputof the tracking, for performing data-flow analysis to determine taintflow from the sources of the taint through data flow paths to sinksusing the taint.

An additional exemplary embodiment is a computer program product,including a computer readable storage medium having computer readableprogram code embodied therewith, the computer readable program codeincluding: code, using a data flow model of a program suitable for taintanalysis of the program, for tracking information from sources of taintto entities in a heap using a model of the heap based on the program,wherein the tracking is performed so that the information is relevantfor taint propagation and is performed in a manner that isfield-sensitive for the entities in the heap; and code, based on outputof the tracking, for performing data-flow analysis to determine taintflow from the sources of the taint through data flow paths to sinksusing the taint.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

FIG. 1 is a code snippet illustrating tracking of tainted access paths;

FIG. 2 is a code snippet without heap issues;

FIG. 3 is a code snippet with heap issues;

FIG. 4 is a visualization of a heap graph for the code snippet of FIG.3;

FIG. 5 is a block diagram of an exemplary logic flow diagram thatillustrates the operation of an exemplary method, a result of executionof computer program instructions embodied on a computer readable memory,and/or functions performed by logic implemented in hardware, inaccordance with exemplary embodiments of this invention;

FIG. 6 is a block diagram of an exemplary logic flow diagram thatillustrates the exemplary operation of a block in FIG. 5 and further anexemplary method, a result of execution of computer program instructionsembodied on a computer readable memory, and/or functions performed bylogic implemented in hardware, in accordance with exemplary embodimentsof this invention; and

FIG. 7 is a block diagram of a system suitable for performing exemplaryembodiments of the instant invention.

DETAILED DESCRIPTION

Exemplary embodiments herein are described through reference to FIGS.1-7. In particular, description of certain blocks of FIGS. 5 and 6 areinterspersed with reference to other figures. FIG. 5 is a block diagramof an exemplary logic flow diagram that illustrates the operation of anexemplary method, a result of execution of computer program instructionsembodied on a computer readable memory, and/or functions performed bylogic implemented in hardware, in accordance with exemplary embodimentsof this invention, and FIG. 6 is a similar block diagram for operationsperformed by one block in FIG. 5.

By way of introduction, taint analysis is performed to determine tainteddata flows by modeling statically (i.e., without execution of theprogram) a program. Taint analysis may be performed to output a set oftainted paths through the program. Taint analysis may be furtherperformed, for instance, to examine the set of tainted paths and performadditional analysis on the tainted paths, such as by determining whetherany of the tainted paths have a proper operation (e.g., at a properlocation) performed on tainted data to render the data safe. Thisadditional analysis reduces the number of tainted paths.

As described above, regardless of the taint analysis being performed,somehow taint has to be tracked from sources of taint to sinks that usetaint. The rest of this disclosure assumes that a data flow model of aprogram has been created (block 510 of FIG. 5) that is suitable fortaint analysis and that contains data flow paths. Such data flow modelsinclude a directed graph such as a call graph or supergraph. It is notedthe block 515 is described below.

There is a relationship between entities in the heap and the data flowsin the call graph. Specifically, entities in the heap such as localvariable and fields that reference objects are potentially part of dataflows that can therefore pass tainted information. However, because ofaliasing in the heap, where aliasing includes multiple local names inthe heap for the same object, unless the aliasing is tracked and managedin a field-sensitive manner, all of the affected data flows may not befound. For instance, the variables p and r may refer to the same object,but in a typical analysis of the heap, they may have the same localnames and therefore taint may be associated with only one of thevariables.

In block 520 of FIG. 5, therefore, tracking of information is performedfrom sources of taint to entities (e.g., local variables and fields thatreference objects) in the heap using a model of the heap. The trackingis performed so that the information is relevant for taint propagationand is performed in a manner that is field-sensitive. The next portionof this disclosure provides additional detail on this block.

One way to tract taint is via access paths. To uncover vulnerabledata-flow paths, a taint analysis should maintain the set of all heaplocations for a program that store untrusted values. A naïve way ofdoing this is to explicitly model the entire heap, including all benignlocations, and then track—at each point during the analysis—whichportions of the heap are tainted. This solution is, in general,prohibitively expensive, and thus also unscalable, as demonstrated,e.g., in O. Tripp, M. Pistoia, S. J. Fink, M. Sridharan, and O. Weisman,TAJ: Effective Taint Analysis of Web Applications, in Proceedings of the2009 ACM SIGPLAN conference on Programming language design andimplementation, 2009. An exemplary solution herein uses a storeless viewof the heap (see A. Deutsch, A Storeless Model of Aliasing and ItsAbstractions Using Finite Representations of Right-regular EquivalenceRelations, in Proceedings of the 1992 International Conference onComputer Languages, 1992), which—instead of representing the heapexplicitly—tracks only information relevant for taint propagation;namely, which sequences of local variable and field dereferences maylead to untrusted data. To describe how an exemplary analysis trackstaint, it first presented how the storeless representation applies inthe concrete setting: A standard concrete semantics is assumed for theproblem of taint analysis, where a program state and an evaluation of anexpression in a program state are defined. The following semanticdomains are used:

L ε objects v ε Val = objects∪{null} ρ Env = VarId → Val h ε Heap =objects × FieldId → Val σ = 

 L,ρ,h 

ε States = 2^(objects) × Env × Heapwhere objects represents an unbounded set of dynamically allocatedobjects, and VarId and FieldId are sets of local variables and fieldidentifiers, respectively. Additionally, ε means “is an element of”, ∪means union, → means “maps to”, and × means Cartesian product, whichconsists of the set of all the pairs obtained by taking an element fromthe first set and an element from the second set: A×B={(a, b): aεA, bεB.A program state, σ, thus maintains the set L of allocated objects, anenvironment ρ mapping local variables to values, and a mapping h fromfields of allocated objects to values.

As motivated above, the data-flow analysis carried out by an exemplaryanalysis is based on the notion of an “access path” (see S. Fink, E.Yahav, N. Dor, G. Ramalingam, and E. Geay, Effective TypestateVerification in the Presence of Aliasing, in ACM International Symposiumon Software Testing and Analysis, 2006). Formally, an access path is apair,

v,

f1, . . . , fn

, where v is a local variable, and f1, . . . , fn are field identifiers(which identify fields in objects, where a field stores state of anobject). The evaluation of access path

v,

f1, . . . , fn

in a concrete state σ with an environment ρ and a heap h yields theunique heap-allocated object o satisfying the following condition:∃o ₁ , . . . , o _(n) ·o ₁=ρ(v)

o ₂ =h(o ₁, f₁)

. . .

o=h(o _(n) , fn),such that o, o₁, . . . , o_(n)εL, where L is the set of allocatedobjects in σ. Additionally, ∃ means “there exists”, “·” means “suchthat”, and

means “and”. If no such object o exists, then the result of theevaluation is a failure, ⊥.

The set of all access paths evaluating to object o in state σ is a soundrepresentation of object o, in that aliasing between access paths ismade explicit, and so flows through the heap can be treated in a soundmanner. Unfortunately, this set is, in general, not guaranteed to befinite even in the concrete setting, due to cycles in the heap (e.g.,caused by recursive structures and back pointers). Even if the set isfinite, deeply nested objects can produce very long chains.

This mandates in an exemplary embodiment a bound, k, on the length oftracked access paths for the static analysis to be tractable. An accesspath of length greater than k is then soundly approximated (or widened)by replacing its suffix, beyond the first k field identifiers, by aspecial symbol, *. The evaluation of widened access path

v,

f1, . . . , fk,*

in concrete state σ yields all the objects in L that are reachable via(zero or more) heap edges from the object

v,

f1, . . . , fk

. In practice, it has been found that setting k=5 works well.

Access paths are a natural way of representing taint flows. Consider,for example, the program snippet in FIG. 1. The source statement at line1 produces the seed access path

p,ε

, where ε denotes an empty sequence of field identifiers (empty becausedocument.URL is unknown initially and will be seeded). It is noted thatthe statement “var q={ }” indicates the variable q is initialized to anempty set. Next, the assignment at line 3 results in another taintedaccess path,

r,ε

. The statement at line 4, which writes field f, leads to the emergenceof a third access path,

q,

f

, which reaches the assignment to sink field “location” at line 5, andcauses a vulnerability to be flagged.

To propagate tainted access paths, an exemplary proposed analysisemploys a novel extension of the Reps-Horwitz-Sagiv (RHS) algorithm. SeeT. Reps, S. Horwitz, and M. Sagiv, Precise Interprocedural DataflowAnalysis via Graph Reachability, in Proceedings of the 22nd ACMSIGPLAN-SIGACT symposium on Principles of programming languages, 1995.The RHS algorithm provides a highly precise static-analysis framework totransform numerous data-flow problems into graph-reachability problems.Specifically, taint propagation is seeded at sources. Every time atainted access path is used in an instruction, the analysis accordinglytaints the access paths that are defined in that instruction.

The taint-propagation process is demand driven in the sense that accesspaths are instantiated only when taint reaches the access paths, whichmakes this algorithm very efficient. Another important characteristic ofthis algorithm is that the algorithm is context sensitive: Each methodmay assume multiple taint behaviors depending on the context in which itis invoked—a key requirement for precision.

Furthermore, an exemplary analysis herein enhances RHS since theexemplary analysis can handle issues that involve aliasing relations inthe heap (i.e., multiple local names for the same object). Thischaracteristic is not in the original RHS algorithm, which does not lenditself to modeling problems that involve aliasing relations establishedin different procedures.

First, how an exemplary algorithm works is illustrated in a simple casewithout aliasing issues, and then a discussion is provided as to how theheap is handled.

Regarding a basic taint-analysis algorithm, in the absence of any issueswith heap aliasing, taint analysis is straightforward: a precisemeet-over-all-feasible-paths solution can be computed using a standardReps-Horwitz-Sagiv (RHS) solver. See T. Reps et al., cited above. Howthis works is illustrated using the example in FIG. 2.

The read of “document.URL” at line 7 is a source of taint, whichgenerates tainted access path

p,ε

(e.g., in this simple example, the taint is assigned to p). The value ofp flows to the invocation of “id” at line 9. The analysis of “id”, lines1-3, reveals that this function simply propagates taint from itsparameter to its return value, so the relational summary {x,ε}→

ret,ε

is established for the “id” function (where ret is a privileged symboldenoting the return value of the method) and propagated to the callersof “id”. Note that this relational summary is modular, in the sense thatonce the relational summary is determined for a function, the relationalsummary may simply be reused for each call of the function. It is alsonoted that this relational summary is an aspect of the instantinvention. Applying this summary to the main method at line 9 generatesthe fact that access path

r,ε

is tainted.

The summary {x,ε}→

ret,ε

is said to be relational because if there is another invocation of “id”in the program such that the argument passed to “id” is not tainted, thereturn value will correctly not be tainted in that case. Therefore,while a summary is generated at a callee and propagated to its callers,the summary is applied to a caller only when the relevant preconditionholds in that caller. In this sense, this analysis is context sensitive:Taint propagation is performed based on the calling context. An examplewith two invocations to the “id” method—one with a tainted argument andthe other with a non-tainted argument—will be presented below. It isalso noted that the relational summaries also provide field sensitivity,since the relational summaries also modify fields in the accordance withthe context sensitivity.

Continuing with the example of FIG. 2, the value of the variable r ispassed to the “set” function at line 10. The “set” function (lines 4-6)contains a field-write instruction, which propagates taint from itsfirst argument to field f of its second argument; that is, the functioncreates a non-empty access path. In this case, the function's relationalsummary is {y,ε}→

z,

f

. Applying this summary to the caller of “set” adds the fact that

q,

f

is tainted. This is true because application of the relational summaryto the calling statement of “set (r, q)” yields {r,ε}→

q,

f

. The access path

r,ε

was already determined to be tainted, but the access path

q,

f

was not previously determined to be tainted. When the analysisterminates, it is learned that the access paths

p,ε

,

r,ε

and

q,

f

are tainted, which is a precise result.

Regarding a full taint-analysis algorithm that can handle aliasing, theprogram in FIG. 2 is an aliasing-free program: there are never multiplenames for the same heap location. That is,

q,

f

is the only name for the given location. Suppose, however, that someother variable pointed to the same location; in that case, the rulesabove might cause us to miss the fact that that the field of variable fis also tainted. For example, consider the variables q and s in the verysimilar program in FIG. 3; both variable q and variable s refer to thesame object (object g, which is initially set to an empty set), and soany taint that results from one of them must carry over to the other.Hence, an exemplary taint-analysis algorithm extends the RHS algorithmto also account for heap aliasing based on the pointer-analysis modelcomputed during call-graph construction. That is, in block 510 of FIG.5, a data flow model of program suitable for taint analysis is created.This data flow model may be, e.g., a directed graph such as a call graphor supergraph and will contain (e.g., representations of) data flowpaths. Creation of the data flow model may also include computing, e.g.,as part of the data flow model or an adjunct thereto, a pointer analysismodel for variables used by the program (block 515 of FIG. 5). Thepointer analysis model, which may be a points-to graph, is amathematical representation of the heap, usually represented as abipartite graph in which a node can be of one of two types: an instancekey (representing an object abstraction) and a pointer key (representinga field identifier). An edge from an instance key to a pointer keyrepresents the fact that the class of the object represented by theinstance key has a field identifier as the one represented by thepointer key. An edge from a pointer key to an instance key representsthe fact that, during program execution, the field identifierrepresented by the pointer key may point to an object represented by theinstance key.

As one example of block 520 of FIG. 5, e.g., performing tracking ofinformation from sources of taint to entities, where the trackingperformed in a manner that is field-sensitive, is illustrated in block525 of FIG. 5. In block 525, a field-sensitive analysis is performed ofthe pointer analysis model to distinguish fields of abstract objectsfrom each other and fields of different abstract objects from eachother. FIG. 6 is a block diagram of an example of performing afield-sensitive analysis using the pointer analysis model. That is, in afurther exemplary embodiment, to resolve aliasing relations, anabstraction of the pointer-analysis model, a “heap graph”, isconstructed. This occurs in block 605 of FIG. 6. The heap graph is abipartite graph, H=

B∪Δ,X

, where B is the set of environment and heap pointers in theprogram—that is, local variables and fields that reference objects(e.g., via field pointer keys), Δ is the set of object abstractionsparticipating in the pointer-analysis solution, and X is the set ofedges in the graph. Edge p→o from pointer p to abstract object o denotesthat object o may be pointed-to by field p. Edge o→p from abstractobject o to field p denotes that o owns field (e.g., field pointer inthis case) p. This abstraction allows for the construction of such aheap graph because the abstraction is field-sensitive, meaning that theabstraction distinguishes the fields of an abstract object from eachother as well as fields of different abstract objects. See B. G. Ryder,Dimensions of Precision in Reference Analysis of Object-OrientedLanguages, in Proceedings of the 12th international conference onCompiler Construction, 2003, Invited Paper. One visualization for theheap graph for the program in FIG. 3 is illustrated by FIG. 4. In FIG.4, a rectangle with a “q” (for instance) inside the rectangle indicatesa pointer for the local variable “q”; a triangle with a “g” (as anexample) inside the triangle indicates a pointer for field “g”; and thecircles indicate abstract objects.

In the program of FIG. 3, there are two changes compared to FIG. 2. Thefirst change is an additional call to “id” (line 11) which definesvariable s, and the second change is the more complex “set” function(lines 4-7). Analysis at first proceeds as above, finding taint for

p,ε

and

r,ε

.

The call to “set” illustrates the heap issues. The assignment “x.f=y”establishes the summary

y,ε

→

x,

f

, but that is clearly not sufficient: “x.f” refers to the same locationas “zg.f”, and the analysis needs to capture such taint. Sound reasoningabout the effect of a field-write statement requires finding (aconservative approximation of) the set of access paths that are aliasedwith

x,

f

in the lexical scope of “set”. This is not handled by the original RHSalgorithm. The instant exemplary analysis, on the other hand, uncoversthe aliases of

x,

f

as described below.

Every time taint flows into an access path (block 610 of FIG. 6), theinstant exemplary analysis executes a function that is referred toherein as Aliases to determine local aliases (e.g., block 630), and thenproceeds with the RHS-based taint propagation (block 530 of FIG. 5). RHSbased taint propagation is described in T. Reps et al., cited above. Anexample of block 610 of FIG. 6 is illustrated by blocks 620 and 625. Inparticular, in block 620, for functions in the program analyzed for thefirst time, a relational summary is determined that maps inputparameter(s) of the function to return value(s) of the function.Exemplary relational summaries have been described above and are alsodescribed below. In block 625, the relational summary/summaries are usedto determine, in a field-sensitive manner, that taint flows into a givenaccess path. Note that block 620 would be skipped for those functionsthat already have relational summaries.

For a given access path rooted at a local variable, a function Aliasesmay be defined (block 630) that returns all the access paths thatsatisfy the following conditions:

1) The access paths are rooted at local variables (block 635). This isequivalent to testing that is Local(v) evaluates to true.

2) Those local variables belong to the same method (block 640). This isequivalent to testing methodOf(v)=methodOf(w).

3) The access paths alias the given access path (block 650). This isequivalent to testing that the sets of abstract objects obtained withtwo calls to a function (called PathTo herein) have a non-emptyintersection.

In addition to the three conditions (1)-(3), the access paths may be (4)truncated to a length k in block 650.

Mathematically, the Aliases function may use some very intuitiveauxiliary functions, including Truncate, which limits the length of anaccess path to a given bound (e.g., k in block 650), and PathTo, whichcomputes the set of abstract objects that are reachable through a givenaccess path (block 650). In order to compute the set of abstract objectsthat are reachable through a given access path (block 650), a function(called FieldName herein) may be used. The function FieldName, given afield pointer in B, returns the corresponding field identifier inFieldId (i.e., a set of field identifiers, as described above). This isuseful because, as was explained above, the instant exemplary analysisrelies on a field-sensitive algorithm, and as such distinguishes fieldpointer keys of different abstract objects even when such field pointerkeys represent an identically named field. In one sense, for block 630,current abstract objects reachable through a given path can be computedby performing a graph traversal. The examples provided above are onetechnique for performing the graph traversal through a given path, butother techniques may also be used.

In block 660, the access paths determined in block 630 are output (e.g.,returned). In block 530 of FIG. 5, based on output of the trackingperformed in block 520, data-flow analysis is performed to determinetaint flow from the sources of taint through data flow paths to sinksusing the taint. The data-flow analysis may be the RHS-based taintpropagation described in T. Reps et al., cited above. That is, theaccess paths can be correlated with corresponding data flow paths in thedata flow model in order to determine which data flow paths may betainted. In block 535 of FIG. 5, using the tainted data flow paths, oneor more operations are performed based thereon. For instance, in block540, indication of the tainted data flow paths may be output. As anotherexample, in block 545, additional analysis may be performed. Suchanalysis could include determining if any of the tainted data flow pathshave a proper operation rendering the data safe. Once tainted data flowpaths have been found, there are many different options known to thoseskilled in this area, and blocks 540 and 545 are merely two examples ofsuch.

To return to the example of FIGS. 3 and 4, in this example, z is indeeda local variable of the same method (see, e.g., FIG. 3), and the globalpointer analysis records that the g field of an object the g field canname may point to the same object as x; hence the heap path

g,f

for z resolves to the same abstract object as

f

for x. The path is short enough that there is no need to truncate thepath. This is illustrated in FIG. 4, where the path from “set.x” throughf leads to the same abstract object as the path from “set.z” through thefields g and f.

The exemplary analysis, therefore, computes the relational summary

y,ε

→

z,

g,f

for the “set” function. Applying this summary at the caller site (line12) adds access path

s,

g,f

. Once again, this is incomplete, since and q denote the same object,and hence, once again, the operation performed in block 630 of FIG. 6uncovers the additional access paths.

Note that the additional call to “id” (line 11 of FIG. 3) adds no taintinformation, since variable q is not tainted to begin with. Theexemplary context-sensitive taint propagation analysis, discussed above,saves one from adding

s,ε

to the set of tainted access paths, which would have made the analysisvery coarse and generated numerous false positives. In fact, the taintedaccess path

s,

g,f

that is computed for the variable s using the instant example is muchmore precise than just the access path

s,ε

.

This exemplary algorithm for resolving aliasing relations isflow-insensitive with respect to fields, meaning that the algorithm doesnot account for strong updates on fields; i.e., if field f of object ois assigned value v and value w at two different program points, theanalysis conservatively considers field f to point to the set of values{v, w}. Flow insensitivity may be performed when the call graph andpoints-to graph are built (block 510 in FIG. 5 and block 515 in FIG. 5,respectively), and may be further refined when the heap graph is built(block 605 of FIG. 6). Conversely, a flow-sensitive analysis attempts todetermine which write instruction is performed first and which last, andbased on that information the analysis reports that field f points toeither value v or value w.

While flow-sensitive analyses may appear to be more precise, it is notalways sound to use the analyses. This is true, e.g., for JavaScript. InJavaScript, the execution of programs is often event-driven—based, forexample, on the click of a button or the interaction with a UserInterface (UI) gadget—the order of execution of certain routines cannotalways be established. Attempting to assert an order of execution canlead to unsound results. Therefore, to guarantee soundness, in anexemplary embodiment, it was chosen to conservatively make the analysisflow-insensitive with respect to fields.

Inside a procedure, however, the analysis can be flow sensitive withrespect to local variables, and thus account for strong updates on thelocal variables, if a SSA (static single assignment) form is used. Thisis because SSA creates variable versions to make sure that each variablegets assigned only once, which indirectly provides a measure limitingaccess paths to length k.

Turning to FIG. 7, an exemplary system is shown that suitable forperforming exemplary embodiments of the invention. This system comprisesa computer system 700 comprising one or more processors 705, one or morememories 710, one or more user input interfaces 720 (e.g., touchscreeninterfaces, mouse interfaces, keyboard interfaces, and the like) and oneor more network interfaces 725. The one or more memories 710 includecomputer readable code 715 that comprises an application interface 717,such as a Web browser, and a program 780. A user (not shown) of thecomputer system 700 uses the application interface 717 to send theprogram 780 to the computer system 750, which performs taint analysis onthe program 780 and sends back results 797. The computer system 700comprises (as shown in FIG. 7) or is coupled to a display 730 having auser interface 735 through which a user (not shown) can view, e.g.,results 797. The program 780 may also be viewed via user interface 735.

This example is a networked example, where the computer system 700communicates with another computer system 750 comprising one or moreprocessors 755, one or more memories 760, and one or more networkinterfaces 785. The one or more memories 760 comprise computer readablecode 765 comprising a taint analysis program 770, which performs some orall of the operations described above on the program 780 to generate theresults 797. The one or more memories 760 also comprise the program 780,the heap graph 790, the data flow model 795, and the results 797. Inthis example, the data flow model 795 includes a pointer analysis model796, although the two models 795, 796 may be separate. The computersystems 700, 755 communicate via a network 740, e.g., the Internet. Inthis example, the computer system 700 is a client and the computersystem 750 is a server. The application interface 717 may be as simpleas a Web interface to the taint analysis program 770, or could be morecomplex, such as an applet or client program.

In a non-networked example, a user of computer 750 would provide theprogram 780 to the computer system 750, and would receive results 797via, e.g., a display (not shown) in or connected to computer system 750.

As will be appreciated by one skilled in the art, aspects of the presentinvention may be embodied as a system, method or computer programproduct. Accordingly, aspects of the present invention may take the formof an entirely hardware embodiment, an entirely software embodiment(including firmware, resident software, micro-code, etc.) or anembodiment combining software and hardware aspects that may allgenerally be referred to herein as a “circuit,” “module” or “system.”Furthermore, aspects of the present invention may take the form of acomputer program product embodied in one or more computer readablemedium(s) having computer readable program code embodied thereon.

Any combination of one or more computer readable medium(s) may beutilized. The computer readable medium may be a computer readable signalmedium or a computer readable storage medium. A computer readablestorage medium may be, for example, but not limited to, an electronic,magnetic, optical, electromagnetic, infrared, or semiconductor system,apparatus, or device, or any suitable combination of the foregoing. Morespecific examples (a non-exhaustive list) of the computer readablestorage medium would include the following: an electrical connectionhaving one or more wires, a portable computer diskette, a hard disk, arandom access memory (RAM), a read-only memory (ROM), an erasableprogrammable read-only memory (EPROM or Flash memory), an optical fiber,a portable compact disc read-only memory (CD-ROM), an optical storagedevice, a magnetic storage device, or any suitable combination of theforegoing. In the context of this document, a computer readable storagemedium may be any tangible medium that can contain, or store a programfor use by or in connection with an instruction execution system,apparatus, or device.

A computer readable signal medium may include a propagated data signalwith computer readable program code embodied therein, for example, inbaseband or as part of a carrier wave. Such a propagated signal may takeany of a variety of forms, including, but not limited to,electro-magnetic, optical, or any suitable combination thereof. Acomputer readable signal medium may be any computer readable medium thatis not a computer readable storage medium and that can communicate,propagate, or transport a program for use by or in connection with aninstruction execution system, apparatus, or device.

Program code embodied on a computer readable medium may be transmittedusing any appropriate medium, including but not limited to wireless,wireline, optical fiber cable, RF, etc., or any suitable combination ofthe foregoing.

Computer program code for carrying out operations for aspects of thepresent invention may be written in any combination of one or moreprogramming languages, including an object oriented programming languagesuch as Java, Smalltalk, C++ or the like and conventional proceduralprogramming languages, such as the “C” programming language or similarprogramming languages. The program code may execute entirely on theuser's computer, partly on the user's computer, as a stand-alonesoftware package, partly on the user's computer and partly on a remotecomputer or entirely on the remote computer or server. In the latterscenario, the remote computer may be connected to the user's computerthrough any type of network, including a local area network (LAN) or awide area network (WAN), or the connection may be made to an externalcomputer (for example, through the Internet using an Internet ServiceProvider).

Aspects of the present invention are described above with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems) and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer program instructions. These computer program instructions maybe provided to a processor of a general purpose computer, specialpurpose computer, or other programmable data processing apparatus toproduce a machine, such that the instructions, which execute via theprocessor of the computer or other programmable data processingapparatus, create means for implementing the functions/acts specified inthe flowchart and/or block diagram block or blocks.

These computer program instructions may also be stored in a computerreadable medium that can direct a computer, other programmable dataprocessing apparatus, or other devices to function in a particularmanner, such that the instructions stored in the computer readablemedium produce an article of manufacture including instructions whichimplement the function/act specified in the flowchart and/or blockdiagram block or blocks.

The computer program instructions may also be loaded onto a computer,other programmable data processing apparatus, or other devices to causea series of operational steps to be performed on the computer, otherprogrammable apparatus or other devices to produce a computerimplemented process such that the instructions which execute on thecomputer or other programmable apparatus provide processes forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks.

The terminology used herein is for the purpose of describing particularembodiments only and is not intended to be limiting of the invention. Asused herein, the singular forms “a”, “an” and “the” are intended toinclude the plural forms as well, unless the context clearly indicatesotherwise. It will be further understood that the terms “comprises”and/or “comprising,” when used in this specification, specify thepresence of stated features, integers, steps, operations, elements,and/or components, but do not preclude the presence or addition of oneor more other features, integers, steps, operations, elements,components, and/or groups thereof.

The corresponding structures, materials, acts, and equivalents of allmeans or step plus function elements in the claims below are intended toinclude any structure, material, or act for performing the function incombination with other claimed elements as specifically claimed. Thedescription of the present invention has been presented for purposes ofillustration and description, but is not intended to be exhaustive orlimited to the invention in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the artwithout departing from the scope and spirit of the invention. Theembodiment was chosen and described in order to best explain theprinciples of the invention and the practical application, and to enableothers of ordinary skill in the art to understand the invention forvarious embodiments with various modifications as are suited to theparticular use contemplated.

What is claimed is:
 1. An apparatus, comprising: one or more memoriescomprising computer-readable program code; and one or more processors,the one or more processors in response to execution of thecomputer-readable program code causing the apparatus to perform thefollowing: using a data flow model of a program suitable for taintanalysis of the program, tracking information from sources of taint toentities in a heap via aliasing in the heap and using a model of theheap based on the program, wherein the tracking is performed so that theinformation is relevant for taint propagation and is performed in amanner that is field-sensitive for the entities in the heap, and whereintracking information further comprises: performing a field-sensitiveanalysis using a pointer analysis model to distinguish fields ofabstract objects in the heap from each other and fields of differentabstract objects in the heap from each other; determining that taintflows into a particular access path, wherein each access path is a pairlinking a variable with a set of field identifiers, and wherein anevaluation of said access path can yield a unique object allocated inthe heap; determining all access paths, corresponding to the particularaccess path, that meet a set of conditions, using the heap graph; andoutputting the determined access paths that meet the set of conditions;and based on output of the tracking, performing data-flow analysis todetermine taint flow from the sources of the taint through data flowpaths to sinks using the taint.
 2. The apparatus of claim 1, wherein thefield-sensitive analysis distinguishes field pointer keys of differentabstract objects even when such field pointer keys represent anidentically named field.
 3. The apparatus of claim 1, wherein thepointer analysis model comprises a points-to graph.
 4. The apparatus ofclaim 1, wherein the one or more processors are further configured inresponse to execution of the computer-readable program code to cause theapparatus to perform the following: determining the data flow model byanalyzing the program and determining the pointer analysis model byanalyzing the program.
 5. The apparatus of claim 1, wherein performing afield-sensitive analysis using a pointer analysis model furthercomprises creating a heap graph comprising an intersection of a firstset of environment and heap pointers in the program intersected with asecond set of the abstract objects participating in the pointer analysismodel, and further comprising a set of edges connecting elements of thefirst and second sets.
 6. The apparatus of claim 5, wherein first set ofenvironment and heap pointers in the program comprise local variables inthe heap and fields that reference objects in the heap.
 7. The apparatusof claim 6, wherein the evaluation is performed in a certain concretestate of the program with a particular environment and a particular heapto yield the unique object in the particular heap.
 8. The apparatus ofclaim 6, wherein determining that taint flows into a particular accesspath further comprises determining, using a relational summary mappingfor a function in the program, that taint flows into the particularaccess path.
 9. The apparatus of claim 8, wherein determining that taintflows into a particular access path further comprises determining, forthe function in the program that is analyzed for a first time, arelational summary mapping one or more input parameters of the functionto one or more return values of the function.
 10. The apparatus of claim6, wherein the set of conditions comprises: the access paths in the allaccess paths are rooted at local variables; the local variables belongto a same apparatus; and all of the access paths alias the particularaccess path.
 11. The apparatus of claim 10, wherein the set ofconditions further comprises: all of the access paths can be truncatedto specific length.
 12. The apparatus of claim 1, wherein the trackinginformation is performed in a manner that is also flow-insensitive withrespect to fields, wherein in response to a field f of an object o inthe heap being assigned value v and value w at two different programpoints, the field f is considered to point to the set of values.
 13. Theapparatus of claim 12, wherein the tracking information furthercomprises building a call graph and a points-to graph, and wherein flowinsensitivity is performed when at least the call graph and points-tograph are built.
 14. The apparatus of claim 1, wherein the one or moreprocessors are further configured in response to execution of thecomputer-readable program code to cause the apparatus to perform thefollowing: outputting indications of the data flow paths determined tobe tainted by the performing the data-flow analysis.
 15. A computerprogram product, comprising a non-transitory computer readable storagemedium having computer readable program code embodied therewith, thecomputer readable program code comprising: code, using a data flow modelof a program suitable for taint analysis of the program, for trackinginformation from sources of taint to entities in a heap via aliasing inthe heap and using a model of the heap based on the program, wherein thetracking is performed so that the information is relevant for taintpropagation and is performed in a manner that is field-sensitive for theentities in the heap, and wherein tracking information furthercomprises: performing a field-sensitive analysis using a pointeranalysis model to distinguish fields of abstract objects in the heapfrom each other and fields of different abstract objects in the heapfrom each other; determining that taint flows into a particular accesspath, wherein each access path is a pair linking a variable with a setof field identifiers, and wherein an evaluation of said access path canyield a unique object allocated in the heap; determining all accesspaths, corresponding to the particular access path, that meet a set ofconditions, using the heap graph; and outputting the determined accesspaths that meet the set of conditions; and code, based on output of thetracking, for performing data-flow analysis to determine taint flow fromthe sources of the taint through data flow paths to sinks using thetaint.
 16. A method, comprising: using a data flow model of a programsuitable for taint analysis of the program, tracking information fromsources of taint to entities in a heap via aliasing in the heap andusing a model of the heap based on the program, wherein the tracking isperformed so that the information is relevant for taint propagation andis performed in a manner that is field- sensitive for the entities inthe heap, and wherein tracking information further comprises: performinga field-sensitive analysis using a pointer analysis model to distinguishfields of abstract objects in the heap from each other and fields ofdifferent abstract objects in the heap from each other; determining thattaint flows into a particular access path, wherein each access path is apair linking a variable with a set of field identifiers, and wherein anevaluation of said access path can yield a unique object allocated inthe heap; determining all access paths, corresponding to the particularaccess path, that meet a set of conditions, using the heap graph; andoutputting the determined access paths that meet the set of conditions;and based on output of the tracking, performing data-flow analysis todetermine taint flow from the sources of the taint through data flowpaths to sinks using the taint.
 17. The method of claim 16, wherein thefield-sensitive analysis distinguishes field pointer keys of differentabstract objects even when such field pointer keys represent anidentically named field.